<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>你会用到的 15 个前端小知识 | 小恐龙</title><meta name="keywords" content="前端小知识"><meta name="author" content="小恐龙"><meta name="copyright" content="小恐龙"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="一些CSS小技巧">
<meta property="og:type" content="article">
<meta property="og:title" content="你会用到的 15 个前端小知识">
<meta property="og:url" content="http://example.com/2020/11/29/%E4%BD%A0%E4%BC%9A%E7%94%A8%E5%88%B0%E7%9A%84-15-%E4%B8%AA%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%9F%A5%E8%AF%86/index.html">
<meta property="og:site_name" content="小恐龙">
<meta property="og:description" content="一些CSS小技巧">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201129css%E5%B0%8F%E7%9F%A5%E8%AF%86.jpg">
<meta property="article:published_time" content="2020-11-29T09:55:16.000Z">
<meta property="article:modified_time" content="2020-12-16T07:12:22.712Z">
<meta property="article:author" content="小恐龙">
<meta property="article:tag" content="前端小知识">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201129css%E5%B0%8F%E7%9F%A5%E8%AF%86.jpg"><link rel="shortcut icon" href="/my_blog/img/favicon.png"><link rel="canonical" href="http://example.com/2020/11/29/%E4%BD%A0%E4%BC%9A%E7%94%A8%E5%88%B0%E7%9A%84-15-%E4%B8%AA%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%9F%A5%E8%AF%86/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/my_blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><script async="async" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>(adsbygoogle = window.adsbygoogle || []).push({
  google_ad_client: '',
  enable_page_level_ads: 'true'
});</script><script>var GLOBAL_CONFIG = { 
  root: '/my_blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-12-16 15:12:22'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><meta name="referrer" content="no-referrer-when-downgrade" /><meta name="generator" content="Hexo 5.2.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="http://q.qlogo.cn/headimg_dl?dst_uin=1363931801&amp;spec=640&amp;img_type=jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/my_blog/archives/"><div class="headline">文章</div><div class="length-num">8</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/my_blog/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/my_blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201129css%E5%B0%8F%E7%9F%A5%E8%AF%86.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/my_blog/">小恐龙</a></span><span id="menus"><div id="search_button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/my_blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/my_blog/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><h1 class="post-title">你会用到的 15 个前端小知识</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-11-29T09:55:16.000Z" title="发表于 2020-11-29 17:55:16">2020-11-29</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-12-16T07:12:22.712Z" title="更新于 2020-12-16 15:12:22">2020-12-16</time></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="记录一些CSS看到的小技巧"><a href="#记录一些CSS看到的小技巧" class="headerlink" title="记录一些CSS看到的小技巧"></a>记录一些CSS看到的小技巧</h3><blockquote>
<p>作者：隐冬<br><a target="_blank" rel="noopener" href="https://juejin.cn/post/6898168495591292942">https://juejin.cn/post/6898168495591292942</a></p>
</blockquote>
<h4 id="1-css一行文本超出…"><a href="#1-css一行文本超出…" class="headerlink" title="1. css一行文本超出…"></a>1. css一行文本超出…</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">overflow</span>: <span class="selector-tag">hidden</span>;</span><br><span class="line"><span class="selector-tag">text-overflow</span><span class="selector-pseudo">:ellipsis</span>;</span><br><span class="line"><span class="selector-tag">white-space</span>: <span class="selector-tag">nowrap</span>;</span><br></pre></td></tr></table></figure>
<h4 id="2-多行文本超出显示…"><a href="#2-多行文本超出显示…" class="headerlink" title="2.多行文本超出显示…"></a>2.多行文本超出显示…</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">display</span>: <span class="selector-tag">-webkit-box</span>;</span><br><span class="line"><span class="selector-tag">-webkit-box-orient</span>: <span class="selector-tag">vertical</span>;</span><br><span class="line"><span class="selector-tag">-webkit-line-clamp</span>: 3;</span><br><span class="line"><span class="selector-tag">overflow</span>: <span class="selector-tag">hidden</span>;</span><br></pre></td></tr></table></figure>
<h4 id="3-IOS手机容器滚动条滑动不流畅"><a href="#3-IOS手机容器滚动条滑动不流畅" class="headerlink" title="3.IOS手机容器滚动条滑动不流畅"></a>3.IOS手机容器滚动条滑动不流畅</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">overflow</span>: <span class="selector-tag">auto</span>;</span><br><span class="line"><span class="selector-tag">-webkit-overflow-scrolling</span>: <span class="selector-tag">touch</span>;</span><br></pre></td></tr></table></figure>
<h4 id="4-修改滚动条样式"><a href="#4-修改滚动条样式" class="headerlink" title="4.修改滚动条样式"></a>4.修改滚动条样式</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span><span class="selector-pseudo">::-webkit-scrollbar</span> &#123;</span><br><span class="line">    <span class="attribute">display</span>: none;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>div::-webkit-scrollbar 滚动条整体部分<br>div::-webkit-scrollbar-thumb  滚动条里面的小方块，能向上向下移动（或往左往右移动，取决于是垂直滚动条还是水平滚动条）<br>div::-webkit-scrollbar-track  滚动条的轨道（里面装有Thumb）<br>div::-webkit-scrollbar-button 滚动条的轨道的两端按钮，允许通过点击微调小方块的位置。<br>div::-webkit-scrollbar-track-piece 内层轨道，滚动条中间部分（除去）<br>div::-webkit-scrollbar-corner 边角，即两个滚动条的交汇处<br>div::-webkit-resizer 两个滚动条的交汇处上用于通过拖动调整元素大小的小控件<br>注意此方案有兼容性问题，一般需要隐藏滚动条时我都是用一个色块通过定位盖上去，或者将子级元素调大，父级元素使用overflow-hidden截掉滚动条部分。暴力且直接。</p>
<h4 id="5-使用css写出一个三角形角标"><a href="#5-使用css写出一个三角形角标" class="headerlink" title="5.使用css写出一个三角形角标"></a>5.使用css写出一个三角形角标</h4><p>元素宽高设置为0，通过border属性来设置，让其它三个方向的border颜色为透明或者和背景色保持一致，剩余一条border的颜色设置为需要的颜色。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">width</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">height</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">border</span>: <span class="number">5px</span> solid #transparent;</span><br><span class="line">    <span class="attribute">border-top-color</span>: red;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="6-解决ios-audio无法自动播放、循环播放的问题"><a href="#6-解决ios-audio无法自动播放、循环播放的问题" class="headerlink" title="6.解决ios audio无法自动播放、循环播放的问题"></a>6.解决ios audio无法自动播放、循环播放的问题</h4><p>ios手机在使用audio或者video播放的时候，个别机型无法实现自动播放，可使用下面的代码hack。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 解决ios audio无法自动播放、循环播放的问题</span></span><br><span class="line"><span class="keyword">var</span> music = <span class="built_in">document</span>.getElementById(<span class="string">&#x27;video&#x27;</span>);</span><br><span class="line"><span class="keyword">var</span> state = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line"><span class="built_in">document</span>.addEventListener(<span class="string">&#x27;touchstart&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="function"><span class="title">if</span>(<span class="params">state==<span class="number">0</span></span>)</span>&#123;</span><br><span class="line">        music.play();</span><br><span class="line">        state=<span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line"><span class="built_in">document</span>.addEventListener(<span class="string">&quot;WeixinJSBridgeReady&quot;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    music.play();</span><br><span class="line">&#125;, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//循环播放</span></span><br><span class="line">music.onended = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    music.load();</span><br><span class="line">    music.play();</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h4 id="7-水平垂直居中"><a href="#7-水平垂直居中" class="headerlink" title="7.水平垂直居中"></a>7.水平垂直居中</h4><ol>
<li>我一般只使用两种方式 定位 或者 flex，我觉得够用了。<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">width</span>: <span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">position</span>: absolute;</span><br><span class="line">    <span class="attribute">top</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">right</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">bottom</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">left</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">margin</span>: auto;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
<li>父级控制子集居中<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.parent</span> &#123;</span><br><span class="line">    <span class="attribute">display</span>: flex;</span><br><span class="line">    <span class="attribute">justify-content</span>: center;</span><br><span class="line">    <span class="attribute">align-items</span>: center;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="8-隐藏页面元素"><a href="#8-隐藏页面元素" class="headerlink" title="8.隐藏页面元素"></a>8.隐藏页面元素</h4>display-none: 元素不会占用空间，在页面中不显示，子元素也不会显示。<br>opacity-0: 元素透明度将为0，但元素仍然存在，绑定的事件仍旧有效仍可触发执行。<br>visibility-hidden：元素隐藏，但元素仍旧存在，占用空间，页面中无法触发该元素的事件。</li>
</ol>
<h4 id="9-contenteditable"><a href="#9-contenteditable" class="headerlink" title="9.contenteditable"></a>9.contenteditable</h4><p>html中大部分标签都是不可以编辑的，但是添加了contenteditable属性之后，标签会变成可编辑状态。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">contenteditable</span>=<span class="string">&quot;true&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>不过通过这个属性把标签变为可编辑状态后只有input事件，没有change事件。也不能像表单一样通过maxlength控制最大长度。我也忘记我在什么情况下用到过了，后面想起来再补吧。</p>
<h4 id="10-calc"><a href="#10-calc" class="headerlink" title="10.calc"></a>10.calc</h4><p>这是一个css属性，我一般称之为css表达式。可以计算css的值。最有趣的是他可以计算不同单位的差值。很好用的一个功能，缺点是不容易阅读。接盘侠没办法一眼看出20px是啥。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">width</span>: <span class="built_in">calc</span>(<span class="number">25%</span> - <span class="number">20px</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="11-Proxy和Object-defineProperty区别"><a href="#11-Proxy和Object-defineProperty区别" class="headerlink" title="11.Proxy和Object.defineProperty区别"></a>11.Proxy和Object.defineProperty区别</h4><p>Proxy的意思是代理，我一般叫他拦截器，可以拦截对象上的一个操作。用法如下，通过new的方式创建对象，第一个参数是被拦截的对象，第二个参数是对象操作的描述。实例化后返回一个新的对象，当我们对这个新的对象进行操作时就会调用我们描述中对应的方法。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">new</span> <span class="built_in">Proxy</span>(target, &#123;</span><br><span class="line">    <span class="function"><span class="title">get</span>(<span class="params">target, property</span>)</span> &#123;</span><br><span class="line"></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="function"><span class="title">set</span>(<span class="params">target, property</span>)</span> &#123;</span><br><span class="line"></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="function"><span class="title">deleteProperty</span>(<span class="params">target, property</span>)</span> &#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<p>Proxy区别于Object.definedProperty。<br>Object.defineProperty只能监听到属性的读写，而Proxy除读写外还可以监听属性的删除，方法的调用等。<br>通常情况下我们想要监视数组的变化，基本要依靠重写数组方法的方式实现，这也是Vue的实现方式，而Proxy可以直接监视数组的变化。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> list = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];</span><br><span class="line"><span class="keyword">const</span> listproxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(list, &#123;</span><br><span class="line">    <span class="function"><span class="title">set</span>(<span class="params">target, property, value</span>)</span> &#123;</span><br><span class="line">        target[property] = value;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>; <span class="comment">// 标识设置成功</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">list.push(<span class="number">4</span>);</span><br></pre></td></tr></table></figure>
<p>Proxy是以非入侵的方式监管了对象的读写，而defineProperty需要按特定的方式定义对象的属性。</p>
<h4 id="12-Reflect"><a href="#12-Reflect" class="headerlink" title="12.Reflect"></a>12.Reflect</h4><p>他是ES2015新增的对象，纯静态对象也就是不能被实例画，只能通过静态方法的方式调用，和Math对象类似，只能类似Math.random()的方式调用。<br>Reflect内部封装了一系列对对象的底层操作，一共14个，其中1个被废弃，还剩下13个。<br>Reflect的静态方法和Proxy描述中的方法完全一致。也就是说Reflect成员方法就是Proxy处理对象的默认实现。<br>Proxy对象默认的方法就是调用了Reflect内部的处理逻辑，也就是如果我们调用get方法，那么在内部，proxy就是将get原封不动的交给了Reflect，如下。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(obj, &#123;</span><br><span class="line">    <span class="function"><span class="title">get</span>(<span class="params">target, property</span>)</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">Reflect</span>.get(target, property);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<p>Reflect和Proxy没有绝对的关系，我们一般将他们两个放在一起讲是为了方便对二者的理解。<br>那为什么会有Reflect对象呢，其实他最大的用处就是提供了一套统一操作Object的API。<br>判断对象是否存在某一个属性，可以使用in操作符，但是不够优雅，还可以使用Reflect.has(obj, name); 删除一个属性可以使用delete，也可以使用Reflect.deleteProperty(obj, name); 获取所有属性名可以使用Object.keys, 也可以使用Reflect.ownKeys(obj); 我们更推荐使用Reflect的API来操作对象，因为他才是未来。</p>
<h4 id="13-解析get参数"><a href="#13-解析get参数" class="headerlink" title="13.解析get参数"></a>13.解析get参数</h4><p>通过replace方法获取url中的参数键值对，可以快速解析get参数。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> q = &#123;&#125;;</span><br><span class="line">location.search.replace(<span class="regexp">/([^?&amp;=]+)=([^&amp;]+)/g</span>,<span class="function">(<span class="params">_,k,v</span>)=&gt;</span>q[k]=v);</span><br><span class="line"><span class="built_in">console</span>.log(q);</span><br></pre></td></tr></table></figure>

<h4 id="14-解析连接url"><a href="#14-解析连接url" class="headerlink" title="14.解析连接url"></a>14.解析连接url</h4><p>可以通过创建a标签，给a标签赋值href属性的方式，获取到协议，pathname，origin等location对象上的属性。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 创建a标签</span></span><br><span class="line"><span class="keyword">const</span> aEle = <span class="built_in">document</span>.createElement(<span class="string">&#x27;a&#x27;</span>);</span><br><span class="line"><span class="comment">// 给a标签赋值href路径</span></span><br><span class="line">aEle.href = <span class="string">&#x27;/test.html&#x27;</span>;</span><br><span class="line"><span class="comment">// 访问aEle中的属性</span></span><br><span class="line">aEle.protocol; <span class="comment">// 获取协议</span></span><br><span class="line">aEle.pathname; <span class="comment">// 获取path</span></span><br><span class="line">aEle.origin;</span><br><span class="line">aEle.host;</span><br><span class="line">aEle.search;</span><br><span class="line">...</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h4 id="15-JS为什么单线程"><a href="#15-JS为什么单线程" class="headerlink" title="15.JS为什么单线程"></a>15.JS为什么单线程</h4><p>一个简单的原因就是，js在设计之初只是进行一些简单的表单校验，这完全不需要多线程，单线程完全可以胜任这项工作。即便后来前端发展迅速，承载的能力越来越多，也没有发展到非多线程不可的程度。<br>而且还有一个主要的原因，设想一下，如果js是多线程的，在运行时多个线程同时对DOM元素进行操作，那具体以哪个线程为主就是个问题了，线程的调度问题是一个比较复杂的问题。<br>HTML5新的标准中允许使用new Worker的方式来开启一个新的线程，去运行一段单独的js文件脚本，但是在这个新线程中严格的要求了可以使用的功能，比如说他只能使用ECMAScript, 不能访问DOM和BOM。这也就限制死了多个线程同时操作DOM元素的可能。</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">小恐龙</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2020/11/29/%E4%BD%A0%E4%BC%9A%E7%94%A8%E5%88%B0%E7%9A%84-15-%E4%B8%AA%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%9F%A5%E8%AF%86/">http://example.com/2020/11/29/%E4%BD%A0%E4%BC%9A%E7%94%A8%E5%88%B0%E7%9A%84-15-%E4%B8%AA%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%9F%A5%E8%AF%86/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">小恐龙</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/my_blog/tags/%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%9F%A5%E8%AF%86/">前端小知识</a></div><div class="post_share"><div class="social-share" data-image="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201129css%E5%B0%8F%E7%9F%A5%E8%AF%86.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/my_blog/2020/12/02/%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F/"><img class="prev-cover" data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201202%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F.jpg" onerror="onerror=null;src='/my_blog/img/404.jpg'"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">从输入URL到页面展示都经过了什么？</div></div></a></div><div class="next-post pull-right"><a href="/my_blog/2020/11/23/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E7%AE%80%E6%98%93Promise/"><img class="next-cover" data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/Promise-topimage.jpg" onerror="onerror=null;src='/my_blog/img/404.jpg'"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">如何实现一个简易Promise</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/my_blog/2020/12/02/从输入URL到页面展示都经过了什么？/" title="从输入URL到页面展示都经过了什么？"><img class="cover" data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201202%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-02</div><div class="title">从输入URL到页面展示都经过了什么？</div></div></a></div><div><a href="/my_blog/2020/12/28/使用IntersectionObserver-API实现图片懒加载/" title="使用IntersectionObserver API实现图片懒加载"><img class="cover" data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201228IntersectionObserver" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">使用IntersectionObserver API实现图片懒加载</div></div></a></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="http://q.qlogo.cn/headimg_dl?dst_uin=1363931801&amp;spec=640&amp;img_type=jpg" onerror="this.onerror=null;this.src='/my_blog/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">小恐龙</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/my_blog/archives/"><div class="headline">文章</div><div class="length-num">8</div></a></div><div class="card-info-data-item is-center"><a href="/my_blog/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="http://wpa.qq.com/msgrd?v=3&amp;uin=1363931801"><i class="fab fa-qq"></i><span>联系我</span></a></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">你好呀，陌生人。</div></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="card-content"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B0%E5%BD%95%E4%B8%80%E4%BA%9BCSS%E7%9C%8B%E5%88%B0%E7%9A%84%E5%B0%8F%E6%8A%80%E5%B7%A7"><span class="toc-number">1.</span> <span class="toc-text">记录一些CSS看到的小技巧</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-css%E4%B8%80%E8%A1%8C%E6%96%87%E6%9C%AC%E8%B6%85%E5%87%BA%E2%80%A6"><span class="toc-number">1.1.</span> <span class="toc-text">1. css一行文本超出…</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%A4%9A%E8%A1%8C%E6%96%87%E6%9C%AC%E8%B6%85%E5%87%BA%E6%98%BE%E7%A4%BA%E2%80%A6"><span class="toc-number">1.2.</span> <span class="toc-text">2.多行文本超出显示…</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-IOS%E6%89%8B%E6%9C%BA%E5%AE%B9%E5%99%A8%E6%BB%9A%E5%8A%A8%E6%9D%A1%E6%BB%91%E5%8A%A8%E4%B8%8D%E6%B5%81%E7%95%85"><span class="toc-number">1.3.</span> <span class="toc-text">3.IOS手机容器滚动条滑动不流畅</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-%E4%BF%AE%E6%94%B9%E6%BB%9A%E5%8A%A8%E6%9D%A1%E6%A0%B7%E5%BC%8F"><span class="toc-number">1.4.</span> <span class="toc-text">4.修改滚动条样式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-%E4%BD%BF%E7%94%A8css%E5%86%99%E5%87%BA%E4%B8%80%E4%B8%AA%E4%B8%89%E8%A7%92%E5%BD%A2%E8%A7%92%E6%A0%87"><span class="toc-number">1.5.</span> <span class="toc-text">5.使用css写出一个三角形角标</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-%E8%A7%A3%E5%86%B3ios-audio%E6%97%A0%E6%B3%95%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE%E3%80%81%E5%BE%AA%E7%8E%AF%E6%92%AD%E6%94%BE%E7%9A%84%E9%97%AE%E9%A2%98"><span class="toc-number">1.6.</span> <span class="toc-text">6.解决ios audio无法自动播放、循环播放的问题</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-%E6%B0%B4%E5%B9%B3%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD"><span class="toc-number">1.7.</span> <span class="toc-text">7.水平垂直居中</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#8-%E9%9A%90%E8%97%8F%E9%A1%B5%E9%9D%A2%E5%85%83%E7%B4%A0"><span class="toc-number">1.8.</span> <span class="toc-text">8.隐藏页面元素</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-contenteditable"><span class="toc-number">1.9.</span> <span class="toc-text">9.contenteditable</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-calc"><span class="toc-number">1.10.</span> <span class="toc-text">10.calc</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#11-Proxy%E5%92%8CObject-defineProperty%E5%8C%BA%E5%88%AB"><span class="toc-number">1.11.</span> <span class="toc-text">11.Proxy和Object.defineProperty区别</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#12-Reflect"><span class="toc-number">1.12.</span> <span class="toc-text">12.Reflect</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#13-%E8%A7%A3%E6%9E%90get%E5%8F%82%E6%95%B0"><span class="toc-number">1.13.</span> <span class="toc-text">13.解析get参数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#14-%E8%A7%A3%E6%9E%90%E8%BF%9E%E6%8E%A5url"><span class="toc-number">1.14.</span> <span class="toc-text">14.解析连接url</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#15-JS%E4%B8%BA%E4%BB%80%E4%B9%88%E5%8D%95%E7%BA%BF%E7%A8%8B"><span class="toc-number">1.15.</span> <span class="toc-text">15.JS为什么单线程</span></a></li></ol></li></ol></div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/my_blog/2020/12/28/%E4%BB%8A%E5%A4%A9-%E5%81%9A%E4%BA%86%E4%B8%80%E4%BB%B6%E6%9C%89%E6%84%8F%E4%B9%89%E7%9A%84%E4%BA%8B%E6%83%85/" title="今天,做了一件有意义的事情"><img data-lazy-src="https://www.unicef.cn/sites/unicef.org.china/files/styles/media_banner/public/story1.jpg?itok=ZK17tQ8a" onerror="this.onerror=null;this.src='/my_blog/img/404.jpg'" alt="今天,做了一件有意义的事情"/></a><div class="content"><a class="title" href="/my_blog/2020/12/28/%E4%BB%8A%E5%A4%A9-%E5%81%9A%E4%BA%86%E4%B8%80%E4%BB%B6%E6%9C%89%E6%84%8F%E4%B9%89%E7%9A%84%E4%BA%8B%E6%83%85/" title="今天,做了一件有意义的事情">今天,做了一件有意义的事情</a><time datetime="2020-12-28T07:54:31.000Z" title="发表于 2020-12-28 15:54:31">2020-12-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/my_blog/2020/12/28/%E4%BD%BF%E7%94%A8IntersectionObserver-API%E5%AE%9E%E7%8E%B0%E5%9B%BE%E7%89%87%E6%87%92%E5%8A%A0%E8%BD%BD/" title="使用IntersectionObserver API实现图片懒加载"><img data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201228IntersectionObserver" onerror="this.onerror=null;this.src='/my_blog/img/404.jpg'" alt="使用IntersectionObserver API实现图片懒加载"/></a><div class="content"><a class="title" href="/my_blog/2020/12/28/%E4%BD%BF%E7%94%A8IntersectionObserver-API%E5%AE%9E%E7%8E%B0%E5%9B%BE%E7%89%87%E6%87%92%E5%8A%A0%E8%BD%BD/" title="使用IntersectionObserver API实现图片懒加载">使用IntersectionObserver API实现图片懒加载</a><time datetime="2020-12-28T07:00:14.000Z" title="发表于 2020-12-28 15:00:14">2020-12-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/my_blog/2020/12/10/%E4%BD%BF%E7%94%A8require-content-%E5%AE%9E%E7%8E%B0%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E8%87%AA%E5%8A%A8%E5%8C%96/" title="使用require.content()实现前端工程自动化"><img data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/%E4%BD%BF%E7%94%A8require%E5%AE%9E%E7%8E%B0%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E5%8C%96.jpg" onerror="this.onerror=null;this.src='/my_blog/img/404.jpg'" alt="使用require.content()实现前端工程自动化"/></a><div class="content"><a class="title" href="/my_blog/2020/12/10/%E4%BD%BF%E7%94%A8require-content-%E5%AE%9E%E7%8E%B0%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E8%87%AA%E5%8A%A8%E5%8C%96/" title="使用require.content()实现前端工程自动化">使用require.content()实现前端工程自动化</a><time datetime="2020-12-10T05:50:26.000Z" title="发表于 2020-12-10 13:50:26">2020-12-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/my_blog/2020/12/03/JavaScript%E5%B8%B8%E7%94%A8%E7%9A%84JS%E6%96%B9%E6%B3%95/" title="JavaScript常用的JS方法"><img data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201204commonJS.jpg" onerror="this.onerror=null;this.src='/my_blog/img/404.jpg'" alt="JavaScript常用的JS方法"/></a><div class="content"><a class="title" href="/my_blog/2020/12/03/JavaScript%E5%B8%B8%E7%94%A8%E7%9A%84JS%E6%96%B9%E6%B3%95/" title="JavaScript常用的JS方法">JavaScript常用的JS方法</a><time datetime="2020-12-03T02:53:35.000Z" title="发表于 2020-12-03 10:53:35">2020-12-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/my_blog/2020/12/02/%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F/" title="从输入URL到页面展示都经过了什么？"><img data-lazy-src="https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/BlogImages/20201202%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F.jpg" onerror="this.onerror=null;this.src='/my_blog/img/404.jpg'" alt="从输入URL到页面展示都经过了什么？"/></a><div class="content"><a class="title" href="/my_blog/2020/12/02/%E4%BB%8E%E8%BE%93%E5%85%A5URL%E5%88%B0%E9%A1%B5%E9%9D%A2%E5%B1%95%E7%A4%BA%E9%83%BD%E7%BB%8F%E8%BF%87%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F/" title="从输入URL到页面展示都经过了什么？">从输入URL到页面展示都经过了什么？</a><time datetime="2020-12-02T03:43:55.000Z" title="发表于 2020-12-02 11:43:55">2020-12-02</time></div></div></div></div></div></div></div></main><footer id="footer" style="background-image: url(https://myblog-1253518880.cos.ap-guangzhou.myqcloud.com/pageConfig/page_footer.jpg)"><div id="footer-wrap"><div class="copyright">&copy;2020 By 小恐龙</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/my_blog/js/utils.js"></script><script src="/my_blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/my_blog/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})</script><div class="js-pjax"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script type="text/javascript" alpha="-20.8" src="https://www.atool99.com/res/ribbon.min.js?id=312"></script></div></body></html>